package com.jsyl.lwbk.business.constant;

import com.jsyl.lwbk.common.utils.StringUtils;

/**
 * @author xiaoshu
 * @date 2020-12-27 11:05
 * @desc
 **/
public enum MedicalDiagnosisEnum {
    WEIZHNEDUAN(25, "未诊断"),
    ZIBIZHENGQINGXIANG(26, "自闭症倾向"),
    ZIBIZHENGPUXIZHANGAI(27, "自闭症谱系障碍"),
    AISIBOGEZONGHEZHENG(28, "艾斯伯格综合征"),
    FAYUCHIHUAN(29, "发育迟缓(包括语言、社交性迟缓)"),
    ZHILIFAYUZHANGGAI(30, "智力发育障碍"),
    XUEXIZHANGAI(31, "学习障碍"),
    YUYANZHANGAI(32, "语言障碍"),
    QINGXUXINGWEIZHANGAI(33, "情绪行为障碍"),
    QITA(34, "其他");

    private Integer medicalDiagnosisType;

    private String medicalDiagnosisName;

    MedicalDiagnosisEnum(Integer medicalDiagnosisType, String medicalDiagnosisName) {
        this.medicalDiagnosisType = medicalDiagnosisType;
        this.medicalDiagnosisName = medicalDiagnosisName;
    }

    public Integer getMedicalDiagnosisType() {
        return medicalDiagnosisType;
    }

    public void setMedicalDiagnosisType(Integer medicalDiagnosisType) {
        this.medicalDiagnosisType = medicalDiagnosisType;
    }

    public String getMedicalDiagnosisName() {
        return medicalDiagnosisName;
    }

    public void setMedicalDiagnosisName(String medicalDiagnosisName) {
        this.medicalDiagnosisName = medicalDiagnosisName;
    }

    public static MedicalDiagnosisEnum getEnumType(Integer medicalDiagnosisType) {
        MedicalDiagnosisEnum[] medicalDiagnosisEnum = MedicalDiagnosisEnum.values();
        for (int i = 0; i < medicalDiagnosisEnum.length; i++) {
            if (medicalDiagnosisEnum[i].getMedicalDiagnosisType().equals(medicalDiagnosisType)) {
                return medicalDiagnosisEnum[i];
            }
        }
        return null;
    }

    public static String getMedicalDiagnosisStr(String medicalDiagnosisTypeStr) {
        if (StringUtils.isEmpty(medicalDiagnosisTypeStr)) {
            return "未填诊断";
        }
        StringBuilder sb = new StringBuilder();
        String[] medicalDiagnosisTypes = medicalDiagnosisTypeStr.split(",");
        for (String medicalDiagnosisType : medicalDiagnosisTypes) {
            MedicalDiagnosisEnum[] medicalDiagnosisEnum = MedicalDiagnosisEnum.values();
            for (int i = 0; i < medicalDiagnosisEnum.length; i++) {
                if (medicalDiagnosisEnum[i].getMedicalDiagnosisType().equals(Integer.valueOf(medicalDiagnosisType))) {
                    sb.append(medicalDiagnosisEnum[i].getMedicalDiagnosisName());
                    sb.append(",");
                    continue;
                }
            }
        }
        return sb.toString();
    }
}
